<?php
/**
 * Created by PhpStorm.
 * User: 悟能科技
 * Date: 2018/8/15
 * Time: 8:31
 */

namespace app\common\controller;


use think\Controller;

class CardRack extends Controller
{
    //添加
    public function addcardrack($param,$type){
        if ($type == 1) {
            $data['page']['page_title'] = $param['page_title'];
            $data['page']['support_multi'] = $param['support_multi'];
            $data['page']['support_buy_for_self'] = $param['support_buy_for_self '];
            $data['page']['banner_pic_url'] = $param['banner_pic_url'];
            $data['page']['theme_list'] = $param['theme_list'];
            $data['page']['category_list'] = $param['category_list'];
            $data['page']['address'] = $param['address'];
            $data['page']['service_phone'] = $param['service_phone'];
            $data['page']['biz_description'] = $param['biz_description'];
            $data['page']['cell_1'] = $param['cell_1'];
            $data['page']['cell_2'] = $param['cell_2'];
            return $data;
        }
        if ($type == 2){
            $data['page_title'] = $param['page_title'];
            $data['support_multi'] = $param['support_multi'];
            $data['support_buy_for_self'] = $param['support_buy_for_self'];
            $data['banner_pic_url'] = $param['banner_pic_url'];
//            $data['theme_list'] = json_encode($param['theme_list'],JSON_UNESCAPED_UNICODE);
//            $data['category_list'] = json_encode($param['category_list'],JSON_UNESCAPED_UNICODE);;
            $data['address'] = $param['address'];
            $data['service_phone'] = $param['service_phone'];
            $data['biz_description'] = $param['biz_description'];
            $data['cell_1'] = json_encode($param['cell_1'],true);
            $data['cell_2'] = json_encode($param['cell_2'],true);
            return $data;
        }
    }

    //添加
    public function editcardrack($param,$type){
        if ($type == 1) {
            $data['page']['page_title'] = $param['page_title'];
            $data['page']['page_id'] = $param['page_id'];
            $data['page']['banner_pic_url'] = $param['banner_pic_url'];
            $data['page']['theme_list'] = $param['theme_list'];
            $data['page']['category_list'] = $param['category_list'];
            $data['page']['address'] = $param['address'];
            $data['page']['service_phone'] = $param['service_phone'];
            $data['page']['biz_description'] = $param['biz_description'];
            $data['page']['cell_1'] = $param['cell_1'];
            $data['page']['cell_2'] = $param['cell_2'];
            return $data;
        }
        if ($type == 2){
            $data['banner_pic_url'] = $param['banner_pic_url'];
            $data['theme_list_edit'] = json_encode($param['theme_list'],JSON_UNESCAPED_UNICODE);
            $data['category_list'] = json_encode($param['category_list'],JSON_UNESCAPED_UNICODE);;
            $data['address'] = $param['address'];
            $data['service_phone'] = $param['service_phone'];
            $data['biz_description'] = $param['biz_description'];
            $data['cell_1'] = $param['cell_1'];
            $data['cell_2'] = $param['cell_2'];
            return $data;
        }
    }

    //发布数据处理    创建/修改
    public function cardrack($param,$type){
        if ($type == 1) {
            $data['page']['page_title'] = $param['page_title'];
            $data['page']['support_buy_for_self'] = $param['support_buy_for_self']==1?true:false;       //买给自己
            $data['page']['support_multi'] = $param['support_multi']==1?true:false;         //发送至群
            $data['page']['page_title'] = $param['page_title'];                 //标题
            $data['page']['banner_pic_url'] = $param['banner_pic_url'];         //banner
            $data['page']['theme_list'] = json_decode($param['theme_list'],true);             //礼品卡集
            $data['page']['category_list'] = json_decode($param['category_list'],true);       //分类主题
            $data['page']['address'] = $param['address'];                   //地址
            $data['page']['service_phone'] = $param['service_phone'];       //电话
            $data['page']['biz_description'] = $param['biz_description'];       //说明
            $data['page']['cell_1'] = json_decode($param['cell_1'],true);             //自定义
            $data['page']['cell_2'] = json_decode($param['cell_2'],true);             //自定义
            return $data;
        }
        if ($type == 2){
            $data['page']['page_title'] = $param['page_title'];
            $data['page']['page_id'] = $param['page_id'];
            $data['page']['banner_pic_url'] = $param['banner_pic_url'];
            $data['page']['support_buy_for_self'] = $param['support_buy_for_self']==1?true:false;       //买给自己
            $data['page']['support_multi'] = $param['support_multi']==1?true:false;         //发送至群
            $data['page']['theme_list'] = json_decode($param['theme_list'],true);             //礼品卡集
            $data['page']['category_list'] = json_decode($param['category_list'],true);       //分类主题
            $data['page']['address'] = $param['address'];
            $data['page']['service_phone'] = $param['service_phone'];
            $data['page']['biz_description'] = $param['biz_description'];
            $data['page']['cell_1'] = json_decode($param['cell_1'],true);             //自定义
            $data['page']['cell_2'] = json_decode($param['cell_2'],true);             //自定义
            return $data;
        }
    }

    //
    public function qwe()
    {
        $data = [
            'page' => [
                'page_title' => '礼品卡',
//                'support_multi'=>true,
                'support_buy_for_self' => true,
                'banner_pic_url' => 'http://mmbiz.qpic.cn/mmbiz_jpg/VtwMJoicTCCVa0icsMfLnRDxHNY9TqNmib4QHjCMd9VKgc4tTiaVzrhlgylf0xQ94qNIic8kYQa4P8LRBg5s9ajL8jw/0',
                'theme_list' => [
                    [
                        'theme_pic_url' => 'http://mmbiz.qpic.cn/mmbiz_jpg/VtwMJoicTCCVa0icsMfLnRDxHNY9TqNmib4QHjCMd9VKgc4tTiaVzrhlgylf0xQ94qNIic8kYQa4P8LRBg5s9ajL8jw/0',
                        'title' => '礼品卡',
                        'title_color' => '#ddd',
                        'show_sku_title_first' => true,
                        'item_list' => [
                            ['card_id' => 'pCVCLv2olt3nKmrza0MLcQ5xFh7g', 'title' => '礼品测试卡', 'pic_url' => 'http://mmbiz.qpic.cn/mmbiz_jpg/p98FjXy8LafBWIJsGFe7tlPvtBFxXXTPdx5cEuFMcWWsiaR1DyrN5ML3jiaVYZibovA8OrwOylUia6ywvVU6Aqboibw/0', 'desc' => 'asdasdasdasdasdashdgashdgasgd']
                        ],
                        'pic_item_list' => [
                            ['background_pic_url' => 'http://mmbiz.qpic.cn/mmbiz_jpg/p98FjXy8LafBWIJsGFe7tlPvtBFxXXTPdx5cEuFMcWWsiaR1DyrN5ML3jiaVYZibovA8OrwOylUia6ywvVU6Aqboibw/0',
                                'default_gifting_msg' => '生活愉快']
                        ],
                        'category_index' => 0,
                    ]
                ],
                'category_list' => [
                    ['title' => '标题1'], ['title' => '标题2']
                ],
                'address' => '林州市',
                'service_phone' => '6142228   ',
                'biz_description' => '啊实打实打算',
                'cell_1' => ['title' => '会员卡', 'url' => 'os.wunengkeji.com'],
                'cell_2' => ['title' => '文档', 'url' => 'https://mp.weixin.qq.com'],
            ]

        ];
    }
}